﻿je_exp_thousand = {

	icon = "gfx/interface/icons/event_icons/event_portrait.dds"

	immediate = {
		c:SIC = {
			save_scope_as = sic_scope
			add_journal_entry = {
				type = je_exp_thousand_SIC
			}
		}
		random_country = {
			limit = {
				owns_entire_state_region = s:STATE_MALTA
			}
			save_scope_as = malta_scope
		}
		set_variable = choose_commander
		set_variable = garibaldi_redshirts
	}

	complete = {
		any_country = {
			limit = {
				owns_entire_state_region = s:STATE_MALTA
			}
			relations:root >= 10
		}
		this.gdp > c:SIC.gdp
		c:SIC = {
			is_at_war = no
		}
		is_at_war = no
		in_default = no
		taking_loans = no
		gold_reserves > 0 

    	custom_tooltip = {
    		text = exp_thousand_commander
			has_variable = has_thousand_commander
		}
    }

    on_complete = {
		add_journal_entry = {
			type = je_exp_thousand_ongoing
		}
    }

    on_timeout = {
    	set_variable = no_thousand_expedition
    }

    invalid = {
    	NOT = {
    		exists = c:SIC
    	}
    }

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = exp_thousand_goal
			}
		}
	}

	timeout = 730
	weight = 1000

	should_be_pinned_by_default = yes
}

je_exp_thousand_SIC = {

	icon = "gfx/interface/icons/event_icons/event_portrait.dds"

	immediate = {
		random_country = {
			limit = {
				has_journal_entry = je_exp_thousand
			}
			save_scope_as = ita_scope
		}
	}

	complete = {
		radical_fraction = {
			value < 0.15
		}
		NOT = {			
			any_scope_state = {
				turmoil > 0.15
			}
		}
		NOT = {
			any_interest_group = {
				ig_approval <= -5	
			}
			has_journal_entry = je_springtime_of_the_peoples
		}
    }

    on_complete = {
    	set_global_variable = exp_thousand_limited
    }

    fail = {
	    custom_tooltip = {
    		text = exp_thousand_SIC_fail
	    	any_country = {
	    		OR = {
	    			has_variable = no_thousand_expedition
		    		has_journal_entry = je_exp_thousand_ongoing
	    		}

	    	}
	    }
    }

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = exp_thousand_SIC_goal
				trigger = {
					always = yes
				}
			}
		}
	}
	weight = 1000

	should_be_pinned_by_default = yes
}


je_exp_thousand_ongoing = {

	icon = "gfx/interface/icons/event_icons/event_military.dds"

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = exp_thousand.109
			10 = exp_thousand.110
			10 = exp_thousand.111
		}
	}

	immediate = {
		random_scope_character = {
			limit = {
				has_variable = thousand_commander
			}
			save_scope_as = exp_commander
		}
		c:SIC = {
			save_scope_as = sic_scope
			trigger_event = { id = exp_thousand.2 }
		}
		trigger_event = { id = exp_thousand.101 days = 7 }

		set_variable = {
			name = expedition_progress
			value = 0
		}
		set_variable = {
			name = expedition_peril
			value = 1
		}
	}

	complete = {
		custom_tooltip = {
			text = je_exp_thousand_complete
			scope:journal_entry = {
				is_goal_complete = yes
			}
		}
    }

    on_complete = {
    	custom_tooltip = je_exp_thousand_ongoing.tt1
		c:SIC = {
			trigger_event = { id = exp_thousand.3 }
		}
		remove_modifier = modifier_large_expedition_cost
		remove_global_variable = exp_thousand_limited
    }

    fail = {
		custom_tooltip = {
			text = je_exp_thousand_fail
			var:expedition_peril >= 5
		}
    }

	on_fail = {
		c:SIC = {
			trigger_event = { id = exp_thousand.5 }
		}
		remove_modifier = modifier_large_expedition_cost
		remove_global_variable = exp_thousand_limited
	}

	on_timeout = {
			c:SIC = {
			trigger_event = { id = exp_thousand.5 }
		}
		remove_modifier = modifier_large_expedition_cost
		remove_global_variable = exp_thousand_limited
	}

	current_value = {
		value = var:expedition_progress
	}

	goal_add_value = {
		add = 7
	}

    invalid = {
    	NOT = {
    		exists = c:SIC
    	}
    }

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = exp_thousand_ongoing_goal
				trigger = {
					var:expedition_peril < 2
				}
			}
			triggered_desc = {
				desc = exp_thousand_low_peril_loc
				trigger = {
					var:expedition_peril = 2
				}
			}
			triggered_desc = {
				desc = exp_thousand_medium_peril_loc
				trigger = {
					var:expedition_peril = 3
				}
			}
			triggered_desc = {
				desc = exp_thousand_high_peril_loc
				trigger = {
					var:expedition_peril >= 4
				}
			}
		}
	}

	progressbar = yes

	weight = 1000

	timeout = 730

	should_be_pinned_by_default = yes
}